package com.imooc.framework.innerclass;

public class LocalInnerClass {
    private static String outName = "张三";
    private Integer outAge = 18;
    private String localName = "王五";

    public static void outerStaticMethod(){
        System.out.println("outerStaticMethod" + outName);
    }

    public void outerNoStaticMethod(){
        System.out.println("outerNoStaticMethod" + outName + outAge);
    }

    public void LocalMethod(){

        final String localName = "lisi";

        class LocalInner{
            final static String innerName = "张三";
            Integer innerAge = 18;

            public LocalInner(Integer innerAge) {
                this.innerAge = innerAge;
            }

            {
                System.out.println("测试静态内部类非静态代码块");
            }

            public void noStaticMethod(){
                System.out.println("noStaticMethod" + innerName);
                System.out.println("noStaticMethod" + innerAge);

                System.out.println("noStaticMethod" + outName);
                System.out.println("noStaticMethod" + outAge);

                outerStaticMethod();
                outerNoStaticMethod();

                System.out.println("localName" + localName);

                System.out.println("outLocalName" + LocalInnerClass.this.localName);

            }
        }

        class LocalInner2{
            final static String innerName = "张三";
            Integer innerAge = 18;

            public LocalInner2(Integer innerAge) {
                this.innerAge = innerAge;
            }

            {
                System.out.println("测试静态内部类非静态代码块");
            }

            public void noStaticMethod(){
                System.out.println("noStaticMethod" + innerName);
                System.out.println("noStaticMethod" + innerAge);

                System.out.println("noStaticMethod" + outName);
                System.out.println("noStaticMethod" + LocalInner.innerName);

                outerStaticMethod();
                outerNoStaticMethod();

                System.out.println("localName" + localName);

                System.out.println("outLocalName" + LocalInnerClass.this.localName);

                LocalInner localInner = new LocalInner(99);
                localInner.noStaticMethod();

            }
        }


        LocalInner localInner = new LocalInner(99);
        localInner.noStaticMethod();

        String innerName = LocalInner.innerName;
    }

    public static void main(String[] args) {
        LocalInnerClass localInnerClass = new LocalInnerClass();
        localInnerClass.LocalMethod();
    }
}
